package algorithm;

import algorithm.R.*;


public class RandomStrategy extends AlgorithmStrategy {
	private ValueFactory[] factories;

	public RandomStrategy(String filePath, String method, int tcNum,MParameter[] paraList) {
		super(filePath, method, tcNum,paraList);
		this.paraList=paraList;
		if(paraList!=null)
		  factories = new ValueFactory[paraList.length];
		initFactory();
	}

	@Override
	protected void initFactory() {
		if(paraList!=null)	
		for (int i = 0; i < paraList.length; i++) {
			switch (paraList[i].getParaType()) {
			case STRING:
				factories[i] = new RandomStringFactory(tcNum);
				break;
			case INTEGER:
				factories[i] = new RandomIntFactory(tcNum);
				break;
			case DOUBLE:
				factories[i] = new RandomDoubleFactory(tcNum);
				break;
			case CHAR:
				factories[i] = new RandomCharFactory(tcNum);
				break;
			}
		}
	}
    public Object[][] getValues()
    {
    	Object[][] returnvalues=new Object[paraList.length][tcNum];
    	if(paraList!=null)	
    		for (int i = 0; i < paraList.length; i++) {
    			returnvalues[i]=factories[i].getValue(paraList[i].getMin(),paraList[i].getMax());
    		}
    	return returnvalues;
    }
}
